package com.ctvit.cch.web.controller;

import com.ctvit.cch.core.pojo.dto.hot.SocialPlatformAddDTO;
import com.ctvit.cch.core.pojo.dto.hot.SocialPlatformEditDTO;
import com.ctvit.cch.core.pojo.dto.hot.SocialPlatformListDTO;
import com.ctvit.cch.core.pojo.dto.hot.SocialPlatformStatusDTO;
import com.ctvit.cch.core.service.ISocialPlatformService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 社交平台Controller
 *
 * @author heyingcheng
 * @date 2025/7/19
 */
@RestController
@RequestMapping("/social/platform")
public class SocialPlatformController extends BaseController {

    private final ISocialPlatformService socialPlatformService;

    public SocialPlatformController(ISocialPlatformService socialPlatformService) {
        this.socialPlatformService = socialPlatformService;
    }

    /**
     * 查询社交平台列表
     *
     * @param dto 列表参数
     * @return {@link AjaxResult } 列表数据
     */
    @PreAuthorize("@ss.hasPermi('social:platform:list')")
    @GetMapping("/list")
    public TableDataInfo list(SocialPlatformListDTO dto) {
        return socialPlatformService.list(dto);
    }

    /**
     * 获取社交平台详细信息
     *
     * @param id ID
     * @return {@link AjaxResult } 详细信息
     */
    @PreAuthorize("@ss.hasPermi('social:platform:get')")
    @GetMapping(value = "/{id}")
    public AjaxResult get(@PathVariable String id) {
        return success(socialPlatformService.get(id));
    }

    /**
     * 新增社交平台
     *
     * @param dto 新增参数
     * @return {@link AjaxResult } 新增结果
     */
    @PreAuthorize("@ss.hasPermi('social:platform:add')")
    @Log(title = "社交平台", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Validated SocialPlatformAddDTO dto) {
        return toAjax(socialPlatformService.add(dto));
    }

    /**
     * 修改社交平台
     *
     * @param dto 修改参数
     * @return {@link AjaxResult } 修改结果
     */
    @PreAuthorize("@ss.hasPermi('social:platform:edit')")
    @Log(title = "社交平台", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Validated SocialPlatformEditDTO dto) {
        return toAjax(socialPlatformService.edit(dto));
    }

    /**
     * 删除社交平台
     *
     * @param ids ID集合
     * @return {@link AjaxResult } 删除结果
     */
    @PreAuthorize("@ss.hasPermi('social:platform:remove')")
    @Log(title = "社交平台", businessType = BusinessType.DELETE)
    @DeleteMapping
    public AjaxResult remove(@RequestBody List<String> ids) {
        return toAjax(socialPlatformService.removeBatchByIds(ids));
    }

    /**
     * 获取社交平台下拉框列表
     *
     * @return {@link AjaxResult } 下拉框列表
     */
    @PreAuthorize("@ss.hasPermi('hot:list:select')")
    @GetMapping(value = "/select")
    public AjaxResult select() {
        return success(socialPlatformService.select());
    }

    /**
     * 修改社交平台状态
     *
     * @param dto 修改参数
     * @return {@link AjaxResult } 修改结果
     */
    @PreAuthorize("@ss.hasPermi('social:platform:status')")
    @Log(title = "社交平台", businessType = BusinessType.UPDATE)
    @PutMapping("status")
    public AjaxResult status(@RequestBody @Validated SocialPlatformStatusDTO dto) {
        return toAjax(socialPlatformService.status(dto));
    }

}
